package com.ABdolphin.forum.interceptor;

import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class AppInterceptorConfig implements WebMvcConfigurer {
    @Resource
    private LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
       registry.addInterceptor(loginInterceptor)
               .addPathPatterns("/**")
               .excludePathPatterns("/sign-up.html")
               .excludePathPatterns("/sign-in.html")
               .excludePathPatterns("/user/login")
               .excludePathPatterns("/user/register")
               .excludePathPatterns("/user/logout")
               .excludePathPatterns("/swagger*/**")
               .excludePathPatterns("/v3*/**")
               .excludePathPatterns("/dist/**")     //排除所有静态文件
               .excludePathPatterns("/image/**")
               .excludePathPatterns("/**.ioc")
               .excludePathPatterns("/js/**");
    }
}
